
import sys
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.colors
import matplotlib.dates as mdates
from matplotlib.ticker import ScalarFormatter
from matplotlib.ticker import LogFormatter
from matplotlib.ticker import MultipleLocator
from matplotlib.ticker import FormatStrFormatter
from matplotlib.font_manager import findfont, FontProperties  
import matplotlib.font_manager as font_manager
import matplotlib.ticker as mtick
import seaborn as sns
from scipy.stats.mstats import gmean

def calculate_geomean(datay):
	print (datay)
	ret = gmean(datay)
	print (ret)
	return ret

# 读文件
def read_data(file_path):
	data = np.loadtxt(file_path,dtype=str,delimiter=' ')
	return data

def choose(data, x, col):
	return data[data[:, col] == x, 0:]

def filter(data, x):
	return data[data[:, 0] == x, 1:]

def uniqx(data):
	uniq_x = []
	for x in data[:, 0]:
		if x not in uniq_x:
			uniq_x.append(x)
	return np.array(uniq_x)

def avg_all(data, x):
	ret = np.average(data[:, 0] == x, axis = 0)
	return ret